#include<bits/stdc++.h>
using namespace std;

stack<int> dex2oct(int num){
    stack<int> res;
    while(num){
        res.push(num%8);
        num /= 8;
    }
    return res;
}

int main(){
    int num;
    while(cin>>num){
        auto res = dex2oct(num);
        while(!res.empty()){
            cout<<res.top();
            res.pop();
        }
        cout<<endl;
    }
    return 0;
}